home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / demos / plasma_copperrgb / rgbplasma.s next >
Text File  |  1980-01-03  |  10KB  |  413 lines

  1. *****************************************************************************
  2. ;    Program    :    RGB + Plasma
  3. ;    Coder(s):    Prophet/Goldfire UK
  4. ;    Notes    :    Old Effects, but still nice if used propally
  5. ;    Three routines here :-
  6. ;    SINEPLASMA - Boring Yuk!
  7. ;    SLOWRGB - My first RGB version, dunno why I`ve kept it!
  8. ;    FASTRGB - New RGB Version, fastest RGB around??!!??
  9. *****************************************************************************
  10.  
  11.      OPT C-,O+
  12.     Section Mycode,CODE_C
  13.  
  14. START    JMP RUN(PC)
  15.  
  16.     Include ram:hw.s
  17.     Include ram:trig.s
  18.  
  19. Openlib    equ -552
  20. Closelib equ -414            ;...Equates for OS calls...
  21. Oslist equ 38
  22. Forbid  equ -132
  23. Permit  equ -138
  24. gfxname    dc.b    "graphics.library",0
  25. storelist dc.l  0
  26.  
  27. CloseDown:
  28.     lea custom,a5
  29.     move.l 4.w,a6
  30.     bset #1,ciaa+pra        ;Led Off
  31.     jsr forbid(a6)
  32.     blitwait            ;Multitask down so let any Blits end
  33.     lea gfxname,a1
  34.     moveq #0,d0
  35.     jsr openlib(a6)            ;open gfxlib
  36.     move.l d0,a1            ;Put gfx base addr in a1
  37.     move.l oslist(a1),storelist    ;store OS copper addr
  38.     jsr closelib(a6)        ;close gfxlib        
  39.     catchVB
  40.     move #$0020,dmacon(a5)        ;sprite DMA off
  41.     move #$8640,dmacon(a5)
  42.     move #$8100,dmacon(a5)
  43.     move #$4020,intena(a5)        ;Master & VB off
  44.     move.l $6c.w,oldlev3+2
  45.     move.l #level3,$6c.w
  46.     move #$c010,intena(a5)        ;Master & Copper On
  47.     catchVB
  48.     move #$0080,dmacon(a5)
  49.     move.l #Copperlist,cop1lc(a5)
  50.     move #0,copjmp1(a5)
  51.     move #$8080,dmacon(a5)
  52.     rts
  53.  
  54. SetupPointers:    
  55. ;Set up Bitplane Pointers
  56.     move.l    #screen,d0
  57.     move.w    d0,pl0l
  58.     swap    d0
  59.     move.w    d0,pl0h
  60.     swap    d0
  61.     add.l    #10240,d0
  62.     move.w    d0,pl1l
  63.     swap    d0
  64.     move.w    d0,pl1h
  65.     swap    d0
  66.     add.l    #10240,d0
  67.     move.w    d0,pl2l
  68.     swap    d0
  69.     move.w    d0,pl2h
  70.     swap    d0
  71.     add.l    #10240,d0
  72.     move.w    d0,pl3l
  73.     swap    d0
  74.     move.w    d0,pl3h
  75.     rts
  76.  
  77. Restore:    
  78.     bclr #1,ciaa+pra        ;Led On
  79.     move #$7e0,dmacon(a5)        ;Dma (incl nasty blit) off
  80.     move.l storelist(pc),cop1lc(a5)
  81.     move #0,copjmp1(a5)
  82.     move #$83e0,dmacon(a5)
  83.     move #$4010,intena(a5)
  84.     move.l oldlev3+2,$6c.w
  85.     move #$c020,intena(a5)
  86.     jsr permit(a6)
  87.     moveq #0,d0
  88.     rts                ;Go Home.....
  89.  
  90.  
  91. RUN:    bsr    CopperInit
  92.     Bsr    CreateSinus
  93.     bsr    SetupPointers
  94.     bsr    CloseDown
  95. mouse:    btst #6,ciaa+pra
  96.     bne.s mouse    
  97.     bsr.s    Restore
  98.     rts
  99.  
  100. *****************************************************************************
  101. ;    Level 3 interrupt handler.......
  102. *****************************************************************************
  103. level3:
  104.     movem.l a0-a6/d0-d7,-(sp)
  105.     lea custom,a5
  106.      btst #4,(intreqr+1)(a5)        ;Check for copper IR
  107.      beq.s notcopper
  108.  
  109.     ;Move.w    #$0,$DFF180
  110.     Bsr    NewRGB
  111.     ;Bsr    DORGB
  112.     ;Bsr    DoPlasma
  113.     ;Move.w    #$F,$DFF180
  114.  
  115. ;-- Call routine here
  116.     move.w #$10,intreq(a5)        ;Clear IR     
  117. notcopper:
  118.     movem.l (sp)+,a0-a6/d0-d7
  119. oldlev3:
  120.         jmp $0.l     
  121.  
  122. Blanksprite dc.w 0,0
  123. fr    dc.w    50
  124.  
  125.  
  126. *****************************************************************************
  127. ;    Plasma Routines... First of Setup Routines...
  128. *****************************************************************************
  129. CopperHeight    =    200    lines
  130. CopperWidth    =    40    bytes
  131. CopWidthSize    =    ((CopperWidth+1)*4)
  132. CopperSize    =    CopWidthSize*CopperHeight
  133. CopperStart    =    $403ffffe    $703fFFFE
  134.  
  135. CreateSinus:
  136.     Lea    SINETAB,a1
  137.     Lea    SINTAB,a2
  138.     Move.l    #511,d5
  139. SinLoop    Move.w    (a1)+,d0
  140.     Muls    #Copperheight,d0
  141.     Lsr.l    #8,d0
  142.     Lsr.l    #6,d0
  143.     Move.w    d0,(a2)+
  144.     Dbra    d5,SinLoop
  145.     Rts
  146.  
  147. CopperInit:
  148.     Lea    Copper,a0
  149.     Lea    CopperTable,a1
  150.     Move.l    #CopperStart,d0
  151.     Move.l    #(CopperHeight-1),d4
  152. InitLp1    Move.l    d0,(a0)+
  153.     Add.l    #$01000000,d0
  154.     Move.l    #(CopperWidth-1),d5
  155.     Move.l    #$01820000,d1
  156. InitLp2    Move.l    d1,(a0)+
  157.     ;Add.l    #$1,d1
  158.     Dbra    d5,InitLp2
  159.     Dbra    d4,InitLp1
  160.     Rts
  161.  
  162.  
  163. *****************************************************************************
  164. ;    Normal Sine Wave Plasma     Coded by Prophet/Goldfire UK
  165. *****************************************************************************
  166.  
  167. DOPLASMA:
  168.     Move.l    PlasStart,d0
  169.     Lea    CopperTable+(CopperHeight),a1
  170.     Move.l    #32,d1
  171.     Bsr    CopperWiggle
  172.     Add.l    #10,PlasStart
  173.     Rts
  174. PlasStart    dc.l    0
  175.  
  176.  
  177. CopperWiggle:
  178. ;--     INPUTS NEEDED :-    d0=SinePos, a1=CopperCols, d1=SineSpeed
  179.     Lea    Copper+6,a0
  180.     Clr.l    d2
  181.     Move.l    #(CopperWidth-1),d5
  182.     Lea    SinTab,a2
  183.     Move.w    #(CopWidthSize-2),bltdmod(a5)
  184.     Move.w    #0,bltamod(a5)
  185.     Move.l    #-1,bltafwm(a5)
  186.     Move.l    #$09f00000,bltcon0(a5)
  187. WiggleLoop    
  188.     And.w    #1023,d0
  189.     Move.w    (a2,d0),d2
  190.     Lea    (a1,d2.w),a3
  191.     Add.w    d1,d0
  192.     BlitWait
  193.     Move.l    a0,bltdpth(a5)
  194.     Move.l    a3,bltapth(a5)
  195.     Move.w    #(CopperHeight<<6)!1,bltsize(a5)
  196.     Addq.l    #4,a0
  197.     Dbra    d5,WiggleLoop
  198.     Rts
  199.  
  200. *****************************************************************************
  201. ;    Slooow RGB Plasma    Coded by Prophet/Goldfire UK
  202. *****************************************************************************
  203. DORGB:
  204.     Move.l    SineStart,d0
  205.     Lea    CopperTable+(CopperHeight),a1
  206.     Move.w    #8,d1
  207.     Move.w    #$F,d2
  208.     Bsr    CopperWiggle2
  209.     Add.l    #16,SineStart
  210.     
  211.     Move.l    SineStart2,d0
  212.     Lea    CopperTable+(CopperHeight),a1
  213.     Move.w    #12,d1        ;Step
  214.     Move.w    #$F0,d2
  215.     Bsr    CopperWiggle2
  216.     Add.l    #12,SineStart2    ;Speed
  217.  
  218.     Move.l    SineStart3,d0
  219.     Lea    CopperTable+(CopperHeight),a1
  220.     Move.w    #16,d1
  221.     Move.w    #$F00,d2
  222.     Bsr    CopperWiggle2
  223.     Add.l    #10,SineStart3
  224.     Rts
  225.  
  226.  
  227. CopperWiggle2:
  228. ;--     INPUTS NEEDED :-    d0=SinePos, a1=CopperCols, d1=SineSpeed
  229. ;                d2=Mask
  230.     Lea    Copper+6,a0
  231.     Clr.l    d3
  232.     Move.l    #(CopperWidth-1),d5
  233.     Lea    SinTab,a2
  234.     Move.w    d2,bltadat(a5)
  235.     Move.w    #(CopWidthSize-2),bltdmod(a5)
  236.     Move.w    #(CopWidthSize-2),bltcmod(a5)
  237.     Move.w    #0,bltbmod(a5)
  238.     Move.l    #-1,bltafwm(a5)
  239.     Move.l    #$07ca0000,bltcon0(a5)
  240. WiggleLoop2
  241.     And.w    #1023,d0
  242.     Move.w    (a2,d0),d3        
  243.     Lea    (a1,d3.w),a3        ;Copper Position
  244.     BlitWait
  245.     Move.l    a0,bltdpth(a5)
  246.     Move.l    a0,bltcpth(a5)
  247.     Move.l    a3,bltbpth(a5)
  248.     Move.w    #(CopperHeight<<6)!1,bltsize(a5)
  249.     Addq.l    #4,a0
  250.     Add.w    d1,d0            ;Add Step
  251.     Dbra    d5,WiggleLoop2
  252.     Blitwait
  253.     Rts
  254.  
  255. CopperTable:
  256.     REPT    2
  257.     dc.w    0,0,0,0,$111,$111,$111,$111,$222,$222,$222,$222
  258.     dc.w    $333,$333,$333,$333,$444,$444,$444,$444,$555,$555,$555,$555
  259.     dc.w    $666,$666,$666,$666
  260.     dc.w    $777,$777,$777,$777,$888,$888,$888,$888,$999,$999,$999,$999
  261.     dc.w    $aaa,$aaa,$aaa,$aaa,$bbb,$bbb,$bbb,$bbb
  262.     dc.w    $ccc,$ccc,$ccc,$ccc,$ddd,$ddd,$ddD,$ddD,$eeE,$eeE,$eeE,$eeE
  263.     dc.w    $fff,$fff,$fff,$Fff
  264.     dc.w    $eee,$eee,$eee,$eee,$ddd,$ddd,$Ddd,$Ddd,$ccc,$ccc,$Ccc,$ccc
  265.     dc.w    $Bbb,$bbb,$bbb,$bbb
  266.     dc.w    $aaa,$aaa,$Aaa,$aaa,$999,$999,$999,$999,$888,$888,$888,$888
  267.     dc.w    $777,$777,$777,$777,$666,$666,$666,$666,$555,$555,$555,$555
  268.     dc.w    $444,$444,$444,$444,$333,$333,$333,$333,$222,$222,$222,$222
  269.     dc.w    $111,$111,$111,$111 ,0,0,0,0
  270.     ENDR
  271.  
  272. *****************************************************************************
  273. ;    Fast RGB Plasma        Coded by Prophet/Goldfire UK
  274. *****************************************************************************
  275. ;-- Call This
  276. NewRGB
  277.     Move.l    REDST,d0
  278.     Move.l    GREST,d1
  279.     Move.l    BLUST,d2
  280.     Move.l    #6,d3
  281.     Move.l    #10,d4
  282.     Move.l    #14,d5
  283.     Bsr    FastRGB
  284.     Add.l    #6,REDST
  285.     Add.l    #4,GREST
  286.     Add.l    #2,BLUST
  287.     Rts
  288. REDST    dc.l    0
  289. GREST    dc.l    0
  290. BLUST    dc.l    0
  291.  
  292. FastRGB:
  293. ;--     INPUTS NEEDED :-    d0,d1,d2 - Starts d3,d4,d5 - Speeds
  294.     Lea    Copper+6,a0
  295.     Lea    Redbar+(CopperHeight),a1
  296.     Lea    GreenBar+(CopperHeight),a2
  297.     Lea    BlueBar+(CopperHeight),a3
  298.     Lea    SinTab,a4
  299.     Clr.l    d7
  300.     Move.l    #(CopperWidth-1),d6
  301.     Move.w    #(CopWidthSize-2),bltdmod(a5)
  302.     Move.w    #0,bltamod(a5)
  303.     Move.w    #0,bltbmod(a5)
  304.     Move.w    #0,bltcmod(a5)
  305.     Move.l    #-1,bltafwm(a5)
  306.     Move.l    #$0FFE0000,bltcon0(a5)
  307. WiggleLoop3
  308.     And.w    #1023,d0
  309.     And.w    #1023,d1
  310.     And.w    #1023,d2
  311.     BlitWait
  312.     Move.w    (a4,d0),d7        
  313.     Lea    (a1,d7.w),a6        ;Copper Position
  314.     Move.l    a6,bltapth(a5)
  315.     Move.w    (a4,d1),d7        
  316.     Lea    (a2,d7.w),a6        ;Copper Position
  317.     Move.l    a6,bltbpth(a5)
  318.     Move.w    (a4,d2),d7        
  319.     Lea    (a3,d7.w),a6        ;Copper Position
  320.     Move.l    a6,bltcpth(a5)
  321.     Move.l    a0,bltdpth(a5)
  322.     Move.w    #(CopperHeight<<6)!1,bltsize(a5)
  323.     Addq.l    #4,a0
  324.     Add.w    d3,d0            ;Add Step
  325.     Add.w    d4,d1            ;Add Step
  326.     Add.w    d5,d2            ;Add Step
  327.     Dbra    d6,WiggleLoop3
  328.     Blitwait
  329.     Move.l    $4.w,a6
  330.     Rts
  331.  
  332. SineStart    dc.l    0
  333. SineStart2    dc.l    0
  334. SineStart3    dc.l    0
  335.  
  336. SINTAB:
  337.     ds.w    512    ;1k SineTable
  338.  
  339. GreenBAR REPT    4
  340.     dc.w    0,0,0,0,$10,$00,$10,$10,$10,$20,$20,$20
  341.     dc.w    $30,$20,$30,$30,$40,$30,$40,$40,$50,$40,$50,$50,$60,$50,$60,$60
  342.     dc.w    $70,$60,$70,$70,$80,$70,$80,$80,$90,$80,$90,$90,$a0,$90,$a0,$a0,$b0,$a0,$b0,$b0
  343.     dc.w    $c0,$b0,$c0,$c0,$d0,$c0,$D0,$D0,$E0,$d0,$E0,$E0,$f0,$e0,$f0,$f0
  344.     dc.w    $e0,$d0,$e0,$e0,$d0,$c0,$d0,$d0,$c0,$b0,$c0,$c0,$b0,$a0,$b0,$b0
  345.     dc.w    $a0,$90,$a0,$a0,$90,$80,$90,$90,$80,$70,$80,$80
  346.     dc.w    $70,$60,$70,$70,$60,$50,$60,$60,$50,$40,$50,$50
  347.     dc.w    $40,$30,$40,$40,$30,$20,$30,$30,$20,$10,$20,$20,$10,$00,$10,$10
  348.     ENDR
  349. RedBAR    REPT    4
  350.     dc.w    0,0,0,0,$100,$000,$100,$100,$200,$100,$200,$200
  351.     dc.w    $300,$200,$300,$300,$400,$300,$400,$400,$500,$400,$500,$500,$600,$500,$600,$600
  352.     dc.w    $700,$600,$700,$700,$800,$700,$800,$800,$900,$800,$900,$900,$a00,$900,$a00,$a00,$b00,$a00,$b00,$b00
  353.     dc.w    $c00,$b00,$c00,$c00,$d00,$c00,$D00,$D00,$E00,$d00,$E00,$E00,$f00,$e00,$f00,$f00
  354.     dc.w    $e00,$d00,$e00,$e00,$d00,$c00,$d00,$d00,$c00,$b00,$c00,$c00,$b00,$a00,$b00,$b00
  355.     dc.w    $a00,$900,$a00,$a00,$900,$800,$900,$900,$800,$700,$800,$800
  356.     dc.w    $700,$600,$700,$700,$600,$500,$600,$600,$500,$400,$500,$500
  357.     dc.w    $400,$300,$400,$400,$300,$200,$300,$300,$200,$100,$200,$200,$100,$000,$100,$100
  358.     ENDR
  359. BlueBAR    REPT    4
  360.     dc.w    0,0,0,0,$1,$0,$1,$1,$2,$1,$2,$2
  361.     dc.w    $3,$2,$3,$3,$4,$3,$4,$4,$5,$4,$5,$5,$6,$5,$6,$6
  362.     dc.w    $7,$6,$7,$7,$8,$7,$8,$8,$9,$8,$9,$9,$a,$9,$a,$a,$b,$a,$b,$b
  363.     dc.w    $c,$b,$c,$c,$d,$c,$D,$D,$E,$d,$E,$E,$f,$e,$f,$f
  364.     dc.w    $e,$d,$e,$e,$d,$c,$d,$d,$c,$b,$c,$c,$b,$a,$b,$b
  365.     dc.w    $a,$9,$a,$a,$9,$8,$9,$9,$8,$7,$8,$8
  366.     dc.w    $7,$6,$7,$7,$6,$7,$6,$6,$5,$4,$5,$5
  367.     dc.w    $4,$3,$4,$4,$3,$2,$3,$3,$2,$1,$2,$2,$1,$0,$1,$1
  368.     ENDR
  369.  
  370.  
  371. *****************************************************************************
  372. ;    Copperlist...
  373. *****************************************************************************
  374.  
  375. Copperlist:
  376. ;RGB
  377.     dc.w diwstrt,$2a80        
  378.     dc.w diwstop,$2ac0
  379. ;Plasma
  380. ;    dc.w diwstrt,$2a81        
  381. ;    dc.w diwstop,$2ac1
  382.     dc.w ddfstrt,$38
  383.     dc.w ddfstop,$d0        ;Normal screen
  384.     dc.w col0,0
  385.     dc.w bpl1mod,0
  386.     dc.w bpl2mod,0
  387.     dc.w bplcon1,0
  388.     dc.w bpl1ptl
  389. pl0l    dc.w 0,bpl1pth
  390. pl0h    dc.w 0,bpl2ptl    
  391. pl1l    dc.w 0,bpl2pth
  392. pl1h    dc.w 0,bpl3ptl    
  393. pl2l    dc.w 0,bpl3pth
  394. pl2h    dc.w 0,bpl4ptl    
  395. pl3l    dc.w 0,bpl4pth
  396. pl3h    dc.w 0
  397.     dc.w bplcon0,$1200        ;No planes
  398.     ;dc.w $4001,$FF00
  399. copper    ds.b CopperSize
  400.     dc.w col1,0,col0,0,col0,0,col0,0
  401.     dc.w bplcon2,0            ;sprites behind
  402. ;    dc.w $ffdf,$fffe        ;wait for end of NTSC
  403. ;    dc.w $9001,$fffe        ;first line after screen
  404.     dc.w intreq,$8010        ;trigger copper IR
  405.     dc.w $ffff,$fffe        ;endless wait
  406.  
  407. *****************************************************************************
  408. ;    Screens and Banks
  409. *****************************************************************************
  410.  
  411. Screen:     dcb.b    40*256*4,$FF
  412.  
  413.